package com.bjtu.transactionclient.api.constant;

import java.util.Arrays;

public enum  IndexCodeToTable {
    BookTable1("ME","booktable1"),
    BookTable2("MC","booktable2"),
    ProceedingsTable1("CA","proceedingstable1"),
    ProceedingsTable2("CB","proceedingstable2"),
    ProceedingsPaperTable1("CE","proceedingspapertable1"),
    ProceedingsPaperTable2("CC","proceedingspapertable2"),
    JounalTable1("JA","journaltable1"),
    JounalTable2("JB","journaltable1"),
    JournalPapersTable1("JE","journalpaperstable1"),
    JournalPapersTable2("JC","journalpaperstable2"),
    ThesisTable1("DE","thesistable1"),
    ThesisTable2("DC","thesistable2"),
    ReportTable1("RE","reporttable1"),
    ReportTable2("RC","reporttable2");

    private String IndexCode;
    private String TableName;

    private IndexCodeToTable(String indexCode, String tableName) {
        IndexCode = indexCode;
        TableName = tableName;
    }

    public String getIndexCode() {
        return IndexCode;
    }

    public void setIndexCode(String indexCode) {
        IndexCode = indexCode;
    }

    public String getTableName() {
        return TableName;
    }

    public void setTableName(String tableName) {
        TableName = tableName;
    }
    /*
    根据indexcode查找表名
     */

    public static IndexCodeToTable getTableName(String key) {
        return Arrays.asList(IndexCodeToTable.values()).stream()
                .filter(indexcodetotable -> indexcodetotable.getIndexCode().equals(key))
                .findFirst().orElse(null);
    }

}

